package com.exsun.ex1077.app

import com.amap.api.maps.MapsInitializer
import com.exsun.ex1077.BR
import com.exsun.ex1077.BuildConfig
import com.exsun.ex1077.R
import com.exsun.ex1077.network.ApiUrl
import com.zhangping.amap.LocationHelper
import com.zhangping.fastjetpack.app.Constants
import com.zhangping.fastjetpack.base.BaseApp
import com.zhangping.fastjetpack.extend.isAgreePrivacy
import com.zhangping.fastjetpack.network.websocket.WebSocketManager
import xyz.doikki.videoplayer.exo.ExoMediaPlayerFactory
import xyz.doikki.videoplayer.player.VideoViewConfig
import xyz.doikki.videoplayer.player.VideoViewManager

/**
 * 描述：
 * 作者：ZhangPing
 * 创建时间：2022/5/9 10:34
 */
class App : BaseApp() {

    override fun brvModelId() = BR.m

    //蒲公英APP升级秘钥
    //蒲公英账号API的key
    override fun pgyApiKey() = "1bc72849a99a71ae4cc66f081d97d616"
    //蒲公英应该APP的key
    override fun pgyAppKey() = "bfb29997620025ae02697f61104a8159"
    //蒲公英渠道的key
    override fun pgyChannelKey() = BuildConfig.PGY_CHANNEL_KEY

    override fun onCreate() {
        super.onCreate()
        Constants.DEFAULT_THEME_COLOR = R.color.theme
        Constants.DEFAULT_BACK_ICON_ID = R.drawable.back
        Constants.DEFAULT_ACTION_BAR_TITLE_COLOR = R.color.color_222222
        WebSocketManager.init(ApiUrl.WEB_SOCKET_URL)
        VideoViewManager.setConfig(VideoViewConfig.newBuilder()
            .setPlayerFactory(ExoMediaPlayerFactory.create())
            .build())
        if (isAgreePrivacy()){
            MapsInitializer.updatePrivacyShow(this, true, true)
            MapsInitializer.updatePrivacyAgree(this, true)
            LocationHelper.init(this)
        }
    }
}